<?php
 function admin_default(){
    require_once (dirname(__FILE__).'/classes/functions.php');
    global $adminTemplate;
    echo $adminTemplate;    
    $tpl = XTemplate::getInstance();    
    setWebSiteLayout('tpl_admin');
    $action = "";
    if(isset ($_GET['adminaction']) && $_GET['adminaction'] != ""){
        $action = $_GET['adminaction'];
    } else {
        $action = 'adminhome';
    }

    if(!adminIsLogged() && $action  != 'login'){
       redirectToUrl('/admin/?adminaction=login');
    }


    $actionDir = dirname(__FILE__)."/actions/".$action;
    $function = 'execute_'.$action;    
    if(is_dir($actionDir)){        
        @include "$actionDir/defines.php";
        require_once($actionDir."/index.php");

        if(function_exists($function)){
            call_user_func($function);
        }
    }
    $tpl->parse("main.menu");    
 }
?>
